//全选中与全不选中职位资料
function CheckAll(form){
	if(form.checked == true){
		for(var i = 0; i < document.thisForm.elements.length; i++){
			var e = document.thisForm.elements[i];
			if(e.name == 'selectedid' || e.name == 'selected_id[]' || e.name == 'selectall')
				e.checked = true;
		}
	}else{
		for(var i = 0; i < document.thisForm.elements.length; i++){
			var e = document.thisForm.elements[i];
			if(e.name == 'selectedid' || e.name == 'selected_id[]' || e.name == 'selectall')
				e.checked = false;
		}
	}
}
//多选操作
function showconfirm(actionUrl, status){
	var flag = false; //是否有选择职位信息
	for(i = 0; i < document.thisForm.elements.length; i++){
		if(document.thisForm.elements[i].name == "selectedid" || document.thisForm.elements[i].name == "selected_id[]"){
			if(document.thisForm.elements[i].checked == true){
				flag = true;
				break;
			}
		}
	}
	if(flag == false){
		layer.msg("请至少选择一个职位进行相关操作！", {time: 1000});
		return false;
	}

	if(status == '2'){
		layer.confirm('您真的要屏蔽选中的职位吗？', {
			btn: ['确定', '取消'] //按钮
		}, function(){
			document.thisForm.action = actionUrl + "?status=2";
			document.thisForm.submit();
		});
	}else if(status == '1'){
		layer.confirm('您真的要激活选中的职位吗？', {
			btn: ['确定', '取消'] //按钮
		}, function(){
			document.thisForm.action = actionUrl + "?status=1";
			document.thisForm.submit();
		});
	}else if(status == '4'){
		layer.confirm('您真的要删除选中的职位吗？', {
			btn: ['确定', '取消'] //按钮
		}, function(){
			document.thisForm.action = actionUrl + "?status=4";
			document.thisForm.submit();
		});
	}
	else if(status == '5'){//刷新职位
		document.thisForm.action = actionUrl
		document.thisForm.submit();
	}
}

//单条操作
function destroy(url, message){
	layer.confirm(message, {
		btn: ['确定', '取消'] //按钮
	}, function(){
		window.location = url;
	});
}

//多条ajax刷新职位
function ajaxRefresh(url){
	var flag = false; //是否有选择职位信息
	for(i = 0; i < document.thisForm.elements.length; i++){
		if(document.thisForm.elements[i].name == "selectedid" || document.thisForm.elements[i].name == "selected_id[]"){
			if(document.thisForm.elements[i].checked == true){
				flag = true;
				break;
			}
		}
	}
	if(flag == false){
		layer.msg("请至少选择一个职位进行相关操作！", {time: 1000});
		return false;
	}
	$.ajax({
		type: "POST",
		url: url,
		data: $("#thisForm").serialize(),
		dataType: "json",
		success: function(msg){
			if(msg.status=='200'){
				layer.close(refreshOpen);
				layer.msg(msg.message);
			}else{
				layer.msg(msg.message);
			}
		}
	});
}

//ajax加急
function ajaxUrgent(othis, url, id){
	layer.confirm("您真的要加急这个职位吗?加急将消耗10个积分", {
		btn: ['确定', '取消'] //按钮
	}, function(){
		$.ajax({
			type: "get",
			url: url,
			dataType: "json",
			success: function(msg){
				if(msg.status == 200){
					$(othis).addClass("urgent2");
					if($("#postitle_" + id).find(".iurgent").length <= 0){
						$("#postitle_" + id).append('<i class="iurgent"></i>');
					}
				}
				layer.msg(msg.message);
			}
		});
	});
}
